<?php
namespace common\actions;
use yii\base\Action;
use Yii;
/**
 * Created by PhpStorm.
 * User: johnny
 * Date: 17-7-17
 * Time: 下午8:16
 */
class AttachmentDownloadAction extends Action
{
    public function run() {
        $path = Yii::$app->request->get("path");
        $path = iconv("UTF-8", "GBK", $path);
        if (empty($path)) {
            $this->controller->redirect(['index']);
        }
        $file_name = Yii::$app->request->get('file_name');
        $path = Yii::getAlias("@app") . $path;
        Yii::$app->response->sendFile($path, $file_name);
    }
}